package net.hky365.shop.module.system.service.member;

import net.hky365.shop.module.system.api.user.MemberApi;
import net.hky365.shop.module.system.api.user.dto.MemberUserDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * Member Service 实现类
 *
 * @author 芋道源码
 */
@Service
public class MemberServiceImpl implements MemberService {

    @Value("${hky365.info.base-package}")
    private String basePackage;

    @Autowired(required = false)
    private MemberApi memberUserApi;

    @Override
    public String getMemberUserMobile(Long id) {
        return Optional.ofNullable(memberUserApi.getUser(id)).map(MemberUserDTO::getMobile).orElse(null);
    }

    @Override
    public String getMemberUserEmail(Long id) {
        throw new UnsupportedOperationException("暂未实现");
    }

    public MemberUserDTO getMember(Long id) {
        return memberUserApi.getUser(id);
    }
}
